/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ditt.swing;

import java.awt.FlowLayout;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.Date;


/**
 *
 * @author attobra
 */
public class Heure {
    
    public static void main(String[] args){
        
        JFrame fenetre = new JFrame("Quelle heure est il ?");
        
        
        javax.swing.JButton btnHeure = new  JButton("heure actuel");
        
        btnHeure.addActionListener(new ListenerHeure());
        
        
        java.awt.Container panneau  = fenetre.getContentPane();
        
        panneau.add(btnHeure);
        
        fenetre.pack();
        fenetre.setSize(300,200);
        
        fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        fenetre.setVisible(true);
        
        
        
    }
    
    
}

class ListenerHeure implements ActionListener{
    public void actionPerformed(ActionEvent e){
        DateFormat formatHeureJour = DateFormat.getDateTimeInstance();
        String heure = formatHeureJour.format(new Date());     
        JOptionPane.showMessageDialog(null, heure);
        
    }
    
}
